<template>
  <div class="mod-user">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <div class="seacrhMoney">
        <el-form-item>
          <div class="balance-searchMoney">
            商户订单号
            <el-input class="input" v-model="dataForm.userName" placeholder="请输入商户订单号"></el-input>
          </div>
        </el-form-item>
        <el-form-item>
          <div class="balance-searchMoney">
            交易日期
            <el-date-picker v-model="value" type="daterange" value-format="yyyy-MM-dd" class="input" start-placeholder="开始日期" :clearable='false' end-placeholder="结束日期">
            </el-date-picker>
          </div>
        </el-form-item>
      </div>
      <el-form-item>
        <el-button type="primary" @click="demand">查询</el-button>
        <el-button type="primary" @click="empty">清空</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格 -->
    <div class="export">
      <div style="display: flex; justify-content: flex-end;margin-bottom:10px;">
        <!-- <el-button type="primary" @click="exportExcel()">导出Excel</el-button> -->
      </div>
      <el-table :data="dataList" :header-cell-style="{ background: '#FAFAFA' }" v-loading="dataListLoading" style="width: 100%">
        <template slot="empty">
          <img class="machine" src="../../assets/img/machine.svg" alt="" />
          <div style="font-size: 14px; text-align: center">暂无数据</div>
        </template>
        <el-table-column prop="merNo" header-align="center" align="center" label="商户号">
        </el-table-column>
        <el-table-column prop="dealAmount" header-align="center" align="center" label="交易金额(元)">
          <template slot-scope="scope">
            <div>
              {{ scope.row.dealAmount| MoneyFormat }}
            </div>
          </template>
        </el-table-column>
        <el-table-column width="120" prop="merServiceCharge" header-align="center" align="center" label="商户手续费(元)">
          <template slot-scope="scope">
            <div>{{ scope.row.merServiceCharge }}</div>
          </template>
        </el-table-column>

        <el-table-column prop="dealType" header-align="center" align="center" label="交易类型">
          <template slot-scope="scope">
            <div>
              {{ orderStatusOptions[scope.row.dealType] }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="dealDate" header-align="center" align="center" label="交易日期">
        </el-table-column>
        <el-table-column prop="chargeDate" header-align="center" align="center" label="清算日期">
        </el-table-column>
        <el-table-column prop="platformDealNo" header-align="center" align="center" label="平台交易单号">
        </el-table-column>
        <el-table-column prop="merOrderNo" header-align="center" align="center" label="商户订单号">
        </el-table-column>
        <el-table-column prop="originalMerOrderNo" header-align="center" align="center" label="原商户订单号">
        </el-table-column>
        <!-- <el-table-column
        prop="status"
        header-align="center"
        align="center"
        label="提现状态"
      >
        <template slot-scope="scope">
          <div v-if="scope.row.applyStatus === 0" class="orangeMoney">
            提现审批中
          </div>
          <div v-if="scope.row.applyStatus === 1" class="greenMoney">
            完成提现
          </div>
          <div v-if="scope.row.applyStatus === 2" class="grayMoney">
            提现审批未通过
          </div>
        </template>
      </el-table-column> -->
      </el-table>
    </div>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </div>
</template>

<script>
const orderStatusOptions = {
  '01': "支付",
  '02': "退款",
  '03': "提现",
  '04': "充值",
  '05': "转账",
  '08': "退票",
  '09': "余额退款",
  '10': "充退",
};
export default {
  data () {
    return {
      dataForm: {
        userName: "",
      },
      options: [
        {
          value: "0",
          label: "审核中",
        },
        {
          value: "1",
          label: "审核通过",
        },
      ],
      orderStatusOptions,
      cycleNo: "",
      dataList: [],
      pageIndex: 1,
      pageSize: 20,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false,
      dealDateStart: "",
      dealDateEnd: "",
      merOrderNo: "",
      value1: "",
      value: "",
      value2: "",
      city: [],
      dialogVisible: false,
      rejectReason: "",
    };
  },
  activated () {
    this.getDataList();
  },
  methods: {
    // 获取数据列表
    getDataList () {
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl("cassadmin/sumpayDeal/getSysSumpayDealList"),
        method: "get",
        params: this.$http.adornParams({
          merOrderNo: this.merOrderNo,
          dealDateStart: this.dealDateStart,
          dealDateEnd: this.dealDateEnd,
          pageNum: this.pageIndex,
          pageSize: this.pageSize,
        }),
      }).then(({ data }) => {
        if (data.success == 1) {
          this.dataList = data.data.list;
          this.totalPage = data.data.total;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
        this.dataListLoading = false;
      });
    },
    //查询
    demand () {
      this.pageIndex = 1
      this.$http({
        url: this.$http.adornUrl("cassadmin/sumpayDeal/getSysSumpayDealList"),
        method: "get",
        params: this.$http.adornParams({
          merOrderNo: this.dataForm.userName,
          dealDateStart: this.value[0],
          dealDateEnd: this.value[1],
          pageNum: this.pageIndex,
          pageSize: this.pageSize,
        }),
      }).then(({ data }) => {
        if (data.success == 1) {
          this.dataList = data.data.list;
          this.totalPage = data.data.total;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
      });
    },
    //清空
    empty () {
      this.dataForm.userName = ''
      this.value = ''
      this.getDataList()
    },
    // 每页数
    sizeChangeHandle (val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.$http({
        url: this.$http.adornUrl("cassadmin/sumpayDeal/getSysSumpayDealList"),
        method: "get",
        params: this.$http.adornParams({
          merOrderNo: this.dataForm.userName,
          dealDateStart: this.value[0],
          dealDateEnd: this.value[1],
          pageNum: this.pageIndex,
          pageSize: this.pageSize,
        }),
      }).then(({ data }) => {
        if (data.success == 1) {
          this.dataList = data.data.list;
          this.totalPage = data.data.total;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
      });
    },
    // 当前页
    currentChangeHandle (val) {
      this.pageIndex = val;
      this.$http({
        url: this.$http.adornUrl("cassadmin/sumpayDeal/getSysSumpayDealList"),
        method: "get",
        params: this.$http.adornParams({
          merOrderNo: this.dataForm.userName,
          dealDateStart: this.value[0],
          dealDateEnd: this.value[1],
          pageNum: this.pageIndex,
          pageSize: this.pageSize,
        }),
      }).then(({ data }) => {
        if (data.success == 1) {
          this.dataList = data.data.list;
          this.totalPage = data.data.total;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
      });
    },
    // 导出excel
    exportExcel () {
      window.location.href = window.location.href =
        "https://api.xstarlife.com/cassadmin/sumpayDeal/downloadSysSumpayDealList?" + `merOrderNo=${this.merOrderNo}&dealDateStart=${this.dealDateStart}&dealDateEnd=${this.dealDateEnd}`;
    }
  },
};
</script>
<style scoped>
.balance-searchMoney {
  display: flex;
  align-items: center;
}
.input {
  flex: 1;
  margin-left: 5px;
}
.input {
  flex: 1;
  margin-left: 5px;
}
.gary {
  color: #ccc;
}
.export {
  margin-top: 30px;
  background-color: #fff;
  padding: 20px;
  border-radius: 6px;
}
</style>
